home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / demovers / cab_20d / doc / prog / init.c < prev    next >
C/C++ Source or Header  |  1998-10-29  |  5KB  |  145 lines

  1. /*
  2. ** init.c for Inet-Module
  3. ** Initialisation for HTML.APP browser inet-module
  4. **
  5. ** Copyright (C) 1995, Stephane Boisson. All Rights reserved.
  6. ** Login <boisson@worldnet.net>
  7. **
  8. ** Started on  Sun Aug 27 23:41:30 1995 Stephane Boisson
  9. ** Last update Mon Aug 28 00:44:10 1995 Stephane Boisson
  10. **
  11. ** This file can be redistributed under the terms of the GNU General
  12. ** Public Licence.
  13. */
  14.  
  15. #include <unistd.h>
  16. #include "module.h"
  17.  
  18.  
  19. /*--- Prototypes ---*/
  20. long ___CDECL init_module(url_methods_t *out, browser_info_t *in, char *path);
  21. long ___CDECL get_url_info(char *url, long *timep, long *sizep, char *type);
  22. void ___CDECL get_version(char **authorp, long *versionp, long *datep);
  23. long ___CDECL get_url(char *url, char *filename);
  24. long ___CDECL post(char *url,char *content, char *enctype, char *filename);
  25. void ___CDECL restore_module(void);
  26. long ___CDECL mailto(char *url, char *subject, char *filename);
  27.  
  28. /*--- Global variables ---*/
  29. browser_info_t *browser;
  30.  
  31. /* ----------------------------------------------------------------- **
  32. ** init_module - Initialize the module (called by browser)           **
  33. ** ----------------------------------------------------------------- */
  34. long ___CDECL init_module(out, in, path)
  35. url_methods_t *out;  /* struture to fill */
  36. browser_info_t *in;  /* infos about browser */
  37. char *path;    /* module path, '\' terminated */
  38. {
  39.   /*--- Set browser info variable ---*/
  40.   browser = in;
  41.  
  42.   /*--- Fill URL methods structure ---*/
  43.   out->restore = restore_module;
  44.   out->get_url = get_url;
  45.   out->get_url_info = get_url_info;
  46.   out->get_version = get_version;
  47.   out->mailto = mailto;
  48.   out->post = post;
  49.  
  50.   /*--- Initialize other stuffs here ---*/
  51.  
  52.   /*--- Return support ---*/
  53.   return(SUPPORT_HTTP|SUPPORT_FTP);
  54. }
  55.  
  56. /* ----------------------------------------------------------------- **
  57. ** mailto - Sends file <filename> as mail to url                     **
  58. ** ----------------------------------------------------------------- */
  59. long ___CDECL mailto(url, subject, filename);
  60. char *url;         /* URL: 'mailto:user@address' */
  61. char *subject;     /* Subject for mail */
  62. char *filename;    /* File */
  63. {
  64.  
  65.   return 0;
  66. }
  67.  
  68. /* ----------------------------------------------------------------- **
  69. ** get_version - Returns infos about module                          **
  70. ** ----------------------------------------------------------------- */
  71. void ___CDECL get_version(authorp, versionp, datep)
  72. char **authorp;   /* 4x30 chars separated by '|' */
  73. long *versionp;   /* Version number in BCD format (V1.15 -> 0x00011500) */
  74. long *datep;   /* Date in BCD format (0xYYYYMMDD) */
  75. {
  76.    *versionp = 0x00010000L;
  77.    *datep = 0x19950827L;
  78.    *authorp = "Stephane Boisson|EMAIL: boisson@worldnet.net";
  79. }
  80.  
  81.  
  82. /* ----------------------------------------------------------------- **
  83. ** restore_module - De-initialization                                **
  84. **                  (freeing memory, closing files, etc...)          **
  85. ** ----------------------------------------------------------------- */
  86. void ___CDECL restore_module()
  87. {
  88. }
  89.  
  90.  
  91. /* ----------------------------------------------------------------- **
  92. ** get_url - Fetch URL and write it as a HTML file                   **
  93. **           Returns 0 if OK, else `errno'                           **
  94. ** ----------------------------------------------------------------- */
  95. long ___CDECL get_url(url, filename)
  96. char *url;     /* URL to fetch */
  97. char *filename;      /* file to write to */
  98. {
  99.   return 0;
  100. }
  101.  
  102.  
  103. /* ----------------------------------------------------------------- **
  104. ** post    - Post FORM, fetch result and write it as a HTML file     **
  105. **           Returns 0 if OK, else `errno'                           **
  106. ** ----------------------------------------------------------------- */
  107. long ___CDECL post(url, content, enctype, filename);
  108. char *url;           /* URL to fetch */
  109. char *content;      /* data to post */
  110. char *enctype;      /* format of data */
  111. char *filename;      /* file to write to */
  112. {
  113.   return 0;
  114. }
  115.  
  116.  
  117. /* ----------------------------------------------------------------- **
  118. ** get_url_info - Retreive infos for an URL                          **
  119. **                Returns 0 if OK, else `errno'                      **
  120. ** ----------------------------------------------------------------- */
  121. long ___CDECL get_url_info(url, timep, sizep, type)
  122. char *url;  /* URL */
  123. long *timep;   /* UNIX time */
  124. long *sizep;   /* size of data */
  125. char *type; /* mime type (max len = 250), empty string if unknow */
  126. {
  127.   return 0;
  128. }
  129.  
  130.  
  131. /* ----------------------------------------------------------------- **
  132. ** main - Doesn't useful, but take care that others functions don't  **
  133. **        get `swallowed' by compiler optimizations                  **
  134. ** ----------------------------------------------------------------- */
  135. int main()
  136. {
  137.   static void *array[] = {
  138.     "Needs HTML.APP to run\r\n",
  139.     (void *)BROWSER_MAGIC1, (void *)BROWSER_MAGIC2,
  140.     (void *)BROWSER_MAGIC3, (void *)BROWSER_MAGIC4, init_module};
  141.  
  142.   write(1, array[0], strlen(array[0]));
  143.   return 1;
  144. }
  145.